
from system_mgmt1.filters.system1_filter import System1FilterSet
from system_mgmt1.models.system1_model import System1
from system_mgmt1.serializers.system1_serializer import (
    System1Serializer,
    System1CreateSerializer,
    System1ListSerializer,
    System1RetrieveSerializer,
    System1UpdateSerializer,
    System1PartialUpdateSerializer
)
from common.drf.viewsets import ModelViewSet


class System1ViewSet(ModelViewSet):
    queryset = System1.objects.all()
    serializer_class = System1Serializer
    filter_class = System1FilterSet
    search_fields = ()
    ordering_fields = ("created_time", "updated_time")

    def get_serializer_class(self):
        if self.action == "create":
            return System1CreateSerializer
        if self.action == "list":
            return System1ListSerializer
        if self.action == "retrieve":
            return System1RetrieveSerializer
        if self.action == "update":
            return System1UpdateSerializer
        if self.action == "partial_update":
            return System1PartialUpdateSerializer
        return super(System1ViewSet, self).get_serializer_class()
